package cn.cc.code;

import java.lang.reflect.Array;

public class xuanye {
    static  double sum(int n){
        double sum=1;
        double a;
        for(int i=2; i<=n; i++){
            a=(i%2==0?1.0:-1.0);
            sum+=a/i;
        }
        return sum ;
    }
    static int shangwang(int time){
        int money = 0 ;
        if(time <= 10 ){
            money = 30 ;
        }
        if (10 < time && time < 50 ){
            money = 3 * time ;
        }
        if(time >= 50 ){
            money = 2 * time ;
        }
        return  money  ;
    }
    static int sumAndSort(int[] a){
        for(int i=0;i<10;i++)
            for(int j=0;j<a.length-i-1;j++)
                if(a[j]>a[j+1]){
                    int temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
        int sum = 0 ;
        for(int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
            sum += a[i];
        }
        return sum ;
    }
    public static void main(String args[]){
        //第三题测试
        int[] a = new int[]{31,42,21,50,12,60,81,74,101,93};
        System.err.println(sumAndSort(a));
        //第二题测试
        System.err.println(shangwang(100));
        //第一題测试
        Double sum = sum(4) ;
        System.err.println(sum);
    }
}
